package com.thauanLopes.bacterium;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.TextView;

import com.game.ThauanFramework.BitmapStorage;
import com.game.ThauanFramework.MinhasCoisas;
import com.thauanLopes.bacterium.GameManages.ScoreManager;
import com.thauanLopes.smagasmaga.R;

public class Menu extends Activity {

	private final String TAG = "Activity - Menu";

	ImageButton button_play;
	ImageButton button_credits;
	TextView textView_highScore;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MinhasCoisas.setCurrentActivity(this);
		
		// Por para carregar em Splash Screen
		BitmapStorage.getInstance();
		ScoreManager.Setup();

		// Screen adjustments
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		// Request landscape orientation
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

		Log.i(TAG,
				String.valueOf(getResources().getConfiguration().orientation));

		// if orientation is horizontal
		if (getResources().getConfiguration().orientation == 2) {
			MinhasCoisas.setAbriuActivity(true);

		}

		Create();

	}

	@Override
	protected void onStart() {
		super.onStart();
		Start();
	}

	private void Create() {

		if(MinhasCoisas.isAbriuActivity()){
		setContentView(R.layout.activity_menu);
		
		//SoundManager.getInstance().playLoopingSound(R.raw.aplausos_001, "aplausos");

		this.button_play = (ImageButton) findViewById(R.id.ImageButton_playButton);
		this.button_play.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				
				MinhasCoisas.ChangeActivity(Ac_GamePlay.class);
			}
		});
		
		this.button_credits = (ImageButton) findViewById(R.id.ImageButton_creditsButton);
		this.button_credits.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				MinhasCoisas.ChangeActivity(AcCreditos.class);
			}
		});
		
		
		this.textView_highScore = (TextView) findViewById(R.id.textView_highScore);
		this.textView_highScore.setTypeface(MinhasCoisas.getGameTypeface());
		
		}
	}

	private void Start() {

		if (MinhasCoisas.isAbriuActivity()) {
			int highScore = ScoreManager.getHighScore();
			this.textView_highScore.setText("Max: " + String.valueOf(highScore));
		}
	}

}
